package com.power.sifa.approve.model;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.plf.core.common.annotations.FieldEnumText;
import com.plf.core.common.domain.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
*  申请材料实体类
*/

@Entity
@ApiModel(value="申请材料")
@Data
@Table(name="Apl_matter_attach",schema="sfapprove")
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
//@IdClass(Apl_matter_attach.Apl_matter_attachPK.class) 用于复合组件
public class Apl_matter_attach extends BaseModel implements Serializable {

	private static final long serialVersionUID = 1L;

    @Id
    @Setter(AccessLevel.NONE)
    @ApiModelProperty(value = "nanoid")
    private String id;

    @ApiModelProperty(value = "引用主表id")
    private String applyid;

    @ApiModelProperty(value = "顺序号")
    private Integer sortnum;

    @ApiModelProperty(value = "材料名称")
    private String name;

    @ApiModelProperty(value = "是否必传")
    private Integer require;

    @ApiModelProperty(value = "最大上传数量")
    private Integer maxnum;

    @ApiModelProperty(value = "描述说明")
    private String describe;

    @ApiModelProperty(value = "是否生成下载文件")
    private Integer filedown;

    @ApiModelProperty(value = "文件生成方式")
    private String filemake;

    @ApiModelProperty(value = "引用标准附件id")
    private String stdattachid;

    @ApiModelProperty(value = "模板文件地址")
    private String tplfile;

    @ApiModelProperty(value = "单个附件最大大小（单位：M）")
    private Integer maxfilesize;

    @ApiModelProperty(value = "是否自定义材料")
    private Integer ismanual;

    @ApiModelProperty(value = "删除标识（0：有效，1：删除）")
    private Integer deleted;

    /**
     *  是否必传文本
     */
    @Transient
    @FieldEnumText(eum="yesNo", valuefield="require")
    private String require_text;

    /**
     *  是否生成下载文件文本
     */
    @Transient
    @FieldEnumText(eum="yesNo", valuefield="filedown")
    private String filedown_text;

    /**
     *  是否自定义材料文本
     */
    @Transient
    @FieldEnumText(eum="yesNo", valuefield="ismanual")
    private String ismanual_text;

    /**
     * 附件列表
     */
    @Transient
    private List<Map> fileList;


    public Map<String, Object> parseMap() {
        Map<String, Object> map=new HashMap<>();
        map.put("id", this.getId());
        map.put("applyid", this.getApplyid());
        map.put("sortnum", this.getSortnum());
        map.put("name", this.getName());
        map.put("require_text", this.require_text);
        map.put("require", this.getRequire());
        map.put("maxnum", this.getMaxnum());
        map.put("describe", this.getDescribe());
        map.put("filedown_text", this.filedown_text);
        map.put("filedown", this.getFiledown());
        map.put("filemake", this.getFilemake());
        map.put("stdattachid", this.getStdattachid());
        map.put("tplfile", this.getTplfile());
        map.put("maxfilesize", this.getMaxfilesize());
        map.put("ismanual_text", this.ismanual_text);
        map.put("ismanual", this.getIsmanual());
        map.put("deleted", this.getDeleted());
        return map;
    }

    public String getId() {
        return id;
    }

    public void setId(Serializable id) {
        this.id = (String) id;
    }

    public Serializable getPrimaryKey() {
        return id;
        // return new Apl_matter_attachPK(id, id2); 用于复合主键，请手动创建内部静态类
    }

    public void setPrimaryKey(Serializable key) {
        this.id = (String)key;

        //Apl_matter_attachPK pk = (Apl_matter_attachPK) key; 用于复合主键
        //this.id = pk.getId();
        //this.id2 = pk.getId2();
    }

}
